<?php
class Tourism_goods_category_attribute_model extends BZ_Model
{
    protected $table  = 'tourism_goods_category_attribute';
    protected $table_2  = 'tourism_goods_category';
    protected $table_3  = 'tourism_goods_category_spec';
    /*
     *获取类别下的所有属性
     * */
    public function getAttributeByCategoryId($cid)
    {
        $this->db->where('category_id',$cid);
        return $this->db->get($this->table);
    }
    /*
     *根据attr_id获取 属性规格信息
     * */
    public function getCategoryIdByAttrId($attr_id = 0)
    {
        $this->db->select('category_id');
        $this->db->where('attr_id',$attr_id);
        return $this->db->get($this->table)->row();
    }
    /*
      *根据attr_id获取category_id
      * */
    public function getAttributeInfoByAttrId($attr_id)
    {
        $this->db->where('attr_id',$attr_id);
        return $this->db->get($this->table)->row();
    }
    public function deleteAttribute($attr_id){
        $this->db->where('attr_id',$attr_id);
        return $this->db->delete($this->table);
    }
/*-------------------------------------------------------------------------*/
    public function add($param){
        $this->db->insert($this->table,$param);
        return $this->db->insert_id();

    }
   /* public function getAttributeByAttrId($attr_id){
        $this->db->select('attr_name');
        $this->db->where('attr_id',$attr_id);
        return $this->db->get($this->table)->row();
    }*/
    /*public function getCategoryIdByAttrId($attr_id){
        $this->db->select('category_id');
        $this->db->where('attr_id',$attr_id);
        $result = $this->db->get($this->table)->row();
        return isset($result->category_id)?$result->category_id:'';
    }*/




}